//对axios进行二次封装
import axios from "axios";
//引入进度条
import nProgress from "nprogress";
//引入进度条样式
import 'nprogress/nprogress.css'
const requests = axios.create({
    baseURL:"/mock",
    timeout:5000,
});

requests.interceptors.request.use((config)=>{
    nProgress.start()   //进度条开始
    return config;

});

requests.interceptors.response.use((res)=>{
    nProgress.done()    //进度条结束
   return res.data
},(error)=>{
    return Promise.reject(new Error('faile'))
}
)

export default requests;